package com.vg.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.SlideMenu.chatlove.R;
import com.vg.classSample.Friend;

public class SampleAdapter extends ArrayAdapter<Friend>{
	private ImageView icon;
	private Button bt_name;
	private TextView tv_status;

	public SampleAdapter(Context context) {
		super(context, 0);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_contact, null);
		}
		 icon = (ImageView) convertView.findViewById(R.id.contact_img_user_1);
		 if(getItem(position).getImage() != null)
		 {
			icon.setImageBitmap(getItem(position).getImage());
		 }
		 else
		 {
			 icon.setImageResource(R.drawable.ic_launcher);
			 getItem(position).loadImage();
		 }
		bt_name=(Button)convertView.findViewById(R.id.contact_tv_name_1);
		tv_status = (TextView) convertView.findViewById(R.id.contact_tv_status_1);
		
		
		bt_name.setText(getItem(position).getName());
		tv_status.setText(getItem(position).getStatus());

		return convertView;
	}
}
